home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / p4 / p4-1_2c.lha / p4-1.2c / lib / p4_utils.c < prev    next >
C/C++ Source or Header  |  1993-07-07  |  17KB  |  683 lines

  1. #include "p4.h"
  2. #include "p4_sys.h"
  3.  
  4. char *p4_version()
  5. {
  6.     return(P4_PATCHLEVEL);
  7. }
  8.  
  9. char *p4_machine_type()
  10. {
  11.     return(P4_MACHINE_TYPE);
  12. }
  13.  
  14.  
  15. int p4_initenv(argc, argv)
  16. int *argc;
  17. char **argv;
  18. {
  19.     int i, rc;
  20.     P4BOOL am_slave = FALSE;
  21.  
  22. /*
  23.     char hname[100];
  24.     int hlen = 100;
  25.  
  26.     gethostname(hname,hlen);
  27.     printf("entering p4_initenv on %s\n",hname);
  28. */
  29.     sprintf(whoami_p4, "xm_%d", getpid());
  30.  
  31.     for (i = 0; i < *argc; i++)
  32.     if ((strcmp(argv[i], "-p4amslave") == 0) ||
  33.         (strcmp(argv[i], "-amp4slave") == 0) ||
  34.             (strcmp(argv[i], "-p4amp4slave") == 0))
  35.         am_slave = TRUE;
  36.  
  37.     /*****
  38.     if (am_slave)
  39.     printf("%s: I am a slave\n",hname);
  40.     else
  41.     printf("%s: I am not a slave\n",hname);
  42.     *****/
  43.  
  44. #   if defined(IPSC860) || defined(CM5) || defined(NCUBE)
  45.     if (MYNODE() != 0)
  46.         am_slave = TRUE;
  47. #    endif
  48.  
  49. #   if defined(CM5)
  50.     CMMD_fset_io_mode( stdin,  CMMD_independent );
  51.     CMMD_fset_io_mode( stdout, CMMD_independent );
  52.     CMMD_fset_io_mode( stderr, CMMD_independent );
  53. #   endif
  54.  
  55.     p4_local  = NULL;
  56.     p4_global = NULL;
  57.  
  58.     if (am_slave)
  59.     {
  60. #       if defined(IPSC860)  ||  defined(CM5)  ||  defined(NCUBE)
  61.         if (MYNODE() == 0)
  62.     {
  63. #           if defined(IPSC860_SOCKETS)  ||  defined(CM5_SOCKETS)  ||  defined(NCUBE_SOCKETS)
  64.         rc = rm_start(argc, argv);
  65. #           endif
  66.     }
  67.     else
  68.     {
  69.         rc = ns_start(argc, argv);
  70.     }
  71. #       else
  72.     rc = rm_start(argc, argv);
  73. #       endif
  74.     ALOG_SETUP(p4_local->my_id,ALOG_TRUNCATE);
  75.     }
  76.     else
  77.     {
  78.     rc = bm_start(argc, argv);
  79.         ALOG_MASTER(0,ALOG_TRUNCATE);
  80.         ALOG_DEFINE(BEGIN_USER,"beg_user","");
  81.         ALOG_DEFINE(END_USER,"end_user","");
  82.         ALOG_DEFINE(BEGIN_SEND,"beg_send","");
  83.         ALOG_DEFINE(END_SEND,"end_send","");
  84.         ALOG_DEFINE(BEGIN_RECV,"beg_recv","");
  85.         ALOG_DEFINE(END_RECV,"end_recv","");
  86.         ALOG_DEFINE(BEGIN_WAIT,"beg_wait","");
  87.         ALOG_DEFINE(END_WAIT,"end_wait","");
  88.     }
  89.     ALOG_LOG(p4_local->my_id,BEGIN_USER,0,"");
  90.     return (rc);
  91. }
  92.  
  93. char *p4_shmalloc(n)
  94. int n;
  95. {
  96.     char *rc;
  97.  
  98.     if ((rc = MD_shmalloc(n)) == NULL)
  99.     p4_dprintf("p4_shmalloc returning NULL; request = %d bytes\n",n);
  100.     return (rc);
  101. }
  102.  
  103. P4VOID p4_shfree(p)
  104. char *p;
  105. {
  106.     MD_shfree(p);
  107. }
  108.  
  109. int p4_num_cluster_ids()
  110. {
  111.     return (p4_global->local_slave_count + 1);
  112. }
  113.  
  114. int p4_num_total_ids()
  115. {
  116.     return (p4_global->num_in_proctable);
  117. }
  118.  
  119. int p4_num_total_slaves()
  120. {
  121.     return (p4_global->num_in_proctable - 1);
  122. }
  123.  
  124.  
  125. P4VOID p4_global_barrier(type)
  126. int type;
  127. {
  128.     int dummy[1];
  129.  
  130.     dummy[0] = 0;
  131.     p4_global_op(type, (char *) dummy, 1, sizeof(int), p4_int_sum_op, P4INT);
  132. }
  133.  
  134.  
  135. P4VOID p4_get_cluster_masters(numids, ids)
  136. int *numids, ids[];
  137. {
  138.     int node;
  139.  
  140.     ids[0] = 0;
  141.     *numids = 1;
  142.     for (node = 1; node < p4_global->num_in_proctable; node++)
  143.     {
  144.     if (p4_global->proctable[node].slave_idx != 0)
  145.         continue;
  146.     ids[(*numids)++] = node;
  147.     }
  148. }
  149.  
  150.  
  151. P4VOID p4_get_cluster_ids(start, end)
  152. int *start;
  153. int *end;
  154. {
  155.  
  156.     *start = p4_global->low_cluster_id;
  157.     *end = p4_global->hi_cluster_id;
  158. }
  159.  
  160. /* This is used to figure out the local id of the calling process by
  161.  * indexing into the proctable until you find a hostname and a unix id
  162.  * that are the same as yours.
  163.  */
  164. int p4_get_my_id_from_proc()
  165. {
  166.     int i, my_unix_id;
  167.     struct proc_info *pi;
  168.     struct hostent *myhp, *pghp;
  169.  
  170. #   if (defined(IPSC860)  &&  !defined(IPSC860_SOCKETS))  ||  \
  171.        (defined(CM5)      &&  !defined(CM5_SOCKETS))      ||  \
  172.        (defined(NCUBE)    &&  !defined(NCUBE_SOCKETS))
  173.     return(MYNODE());
  174. #   else
  175.     my_unix_id = getpid();
  176.     if (p4_local->my_id == LISTENER_ID)
  177.     return (LISTENER_ID);
  178.     myhp = gethostbyname_p4(p4_global->my_host_name);
  179.  
  180.     for (pi = p4_global->proctable, i = 0; i < p4_global->num_in_proctable; i++, pi++)
  181.     {
  182.     if (pi->unix_id == my_unix_id)
  183.     {
  184.         if (strcmp(pi->host_name, p4_global->my_host_name) == 0)
  185.         {
  186.         return (i);
  187.         }
  188.         else
  189.         {
  190.         pghp = gethostbyname_p4(pi->host_name);
  191.         if (bcmp(myhp->h_addr, pghp->h_addr, myhp->h_length) == 0)
  192.         {
  193.             return (i);
  194.         }
  195.         }
  196.     }
  197.     }
  198.     p4_dprintf("process not in process table; my_unix_id = %d my_host=%s\n",
  199.            getpid(), p4_global->my_host_name);
  200.     p4_dprintf("Probable cause:  local slave on uniprocessor without shared memory\n");
  201.     p4_dprintf("Probable fix:  ensure only one process on %s\n",p4_global->my_host_name);
  202.     p4_dprintf("(on master process this means 'local 0' in the procgroup file)\n");
  203.     p4_dprintf("You can also remake p4 with SYSV_IPC set in the OPTIONS file\n");
  204.     p4_error("p4_get_my_id_from_proc",0);
  205. #   endif
  206. }
  207.  
  208. int p4_get_my_id()
  209. {
  210.     return (p4_local->my_id);
  211. }
  212.  
  213. int p4_get_my_cluster_id()
  214. {
  215. #   if (defined(IPSC860)  &&  !defined(IPSC860_SOCKETS))  ||  \
  216.        (defined(CM5)      &&  !defined(CM5_SOCKETS))      ||  \
  217.        (defined(NCUBE)    &&  !defined(NCUBE_SOCKETS))
  218.     return(MYNODE());
  219. #   else
  220.     if (p4_local->my_id == LISTENER_ID)
  221.     return (LISTENER_ID);
  222.     else
  223.     return (p4_global->proctable[p4_local->my_id].slave_idx);
  224. #   endif
  225. }
  226.  
  227. P4BOOL p4_am_i_cluster_master()
  228. {
  229.     if (p4_local->my_id == LISTENER_ID)
  230.     return (0);
  231.     else
  232.     return (p4_global->proctable[p4_local->my_id].slave_idx == 0);
  233. }
  234.  
  235. P4BOOL in_same_cluster(i, j)
  236. int i, j;
  237. {
  238.     return (p4_global->proctable[i].group_id ==
  239.         p4_global->proctable[j].group_id);
  240. }
  241.  
  242. P4VOID p4_cluster_shmem_sync(cluster_shmem)
  243. P4VOID **cluster_shmem;
  244. {
  245.     int myid = p4_get_my_cluster_id();
  246.  
  247.     if (myid == 0)  /* cluster master */
  248.     p4_global->cluster_shmem = *cluster_shmem;
  249.     p4_barrier(&(p4_global->cluster_barrier),p4_num_cluster_ids());
  250.     if (myid != 0)
  251.     *cluster_shmem = p4_global->cluster_shmem;
  252. }
  253.  
  254. #if defined(USE_XX_SHMALLOC)
  255. /* This is not machine dependent code but is only used on some machines */
  256.  
  257. /*
  258.   Memory management routines from ANSI K&R C, modified to manage
  259.   a single block of shared memory.
  260.   Have stripped out all the usage monitoring to keep it simple.
  261.  
  262.   To initialize a piece of shared memory:
  263.     xx_init_shmalloc(char *memory, unsigned nbytes)
  264.  
  265.   Then call xx_shmalloc() and xx_shfree() as usual.
  266. */
  267.  
  268. #define LOG_ALIGN 4
  269. #define ALIGNMENT (1 << LOG_ALIGN)
  270.  
  271. /* ALIGNMENT is assumed below to be bigger than sizeof(p4_lock_t) +
  272.    sizeof(Header *), so do not reduce LOG_ALIGN below 4 */
  273.  
  274. union header
  275. {
  276.     struct
  277.     {
  278.     union header *ptr;    /* next block if on free list */
  279.     unsigned size;        /* size of this block */
  280.     } s;
  281.     char align[ALIGNMENT];    /* Align to ALIGNMENT byte boundary */
  282. };
  283.  
  284. typedef union header Header;
  285.  
  286. static Header **freep;        /* pointer to pointer to start of free list */
  287. static p4_lock_t *shmem_lock;    /* Pointer to lock */
  288.  
  289. P4VOID xx_init_shmalloc(memory, nbytes)
  290. char *memory;
  291. unsigned nbytes;
  292. /*
  293.   memory points to a region of shared memory nbytes long.
  294.   initialize the data structures needed to manage this memory
  295. */
  296. {
  297.     int nunits = nbytes >> LOG_ALIGN;
  298.     Header *region = (Header *) memory;
  299.  
  300.     /* Quick check that things are OK */
  301.  
  302.     if (ALIGNMENT != sizeof(Header) ||
  303.     ALIGNMENT < (sizeof(Header *) + sizeof(p4_lock_t)))
  304.     p4_error("xx_init_shmem: Alignment is wrong", ALIGNMENT);
  305.  
  306.     if (!region)
  307.     p4_error("xx_init_shmem: Passed null pointer", 0);
  308.  
  309.     if (nunits < 2)
  310.     p4_error("xx_init_shmem: Initial region is ridiculously small",
  311.          (int) nbytes);
  312.  
  313.     /*
  314.      * Shared memory region is structured as follows
  315.      * 
  316.      * 1) (Header *) freep ... free list pointer 2) (p4_lock_t) shmem_lock ...
  317.      * space to hold lock 3) padding up to alignment boundary 4) First header
  318.      * of free list
  319.      */
  320.  
  321.     freep = (Header **) region;    /* Free space pointer in first block  */
  322.     shmem_lock = (p4_lock_t *) (freep + 1);    /* Lock still in first block */
  323.     (region + 1)->s.ptr = *freep = region + 1;    /* Data in rest */
  324.     (region + 1)->s.size = nunits - 1;    /* One header consumed already */
  325.  
  326. #   ifdef SYSV_IPC
  327.     shmem_lock->semid = sysv_semid0;
  328.     shmem_lock->semnum = 0;
  329. #   else
  330.     p4_lock_init(shmem_lock);                /* Initialize the lock */
  331. #   endif
  332.  
  333. }
  334.  
  335. char *xx_shmalloc(nbytes)
  336. unsigned nbytes;
  337. {
  338.     Header *p, *prevp;
  339.     char *address = (char *) NULL;
  340.     unsigned nunits;
  341.  
  342.     /* Force entire routine to be single threaded */
  343.     (P4VOID) p4_lock(shmem_lock);
  344.  
  345.     nunits = ((nbytes + sizeof(Header) - 1) >> LOG_ALIGN) + 1;
  346.  
  347.     prevp = *freep;
  348.     for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr)
  349.     {
  350.     if (p->s.size >= nunits)
  351.     {            /* Big enuf */
  352.         if (p->s.size == nunits)    /* exact fit */
  353.         prevp->s.ptr = p->s.ptr;
  354.         else
  355.         {            /* allocate tail end */
  356.         p->s.size -= nunits;
  357.         p += p->s.size;
  358.         p->s.size = nunits;
  359.         }
  360.         *freep = prevp;
  361.         address = (char *) (p + 1);
  362.         break;
  363.     }
  364.     if (p == *freep)
  365.     {            /* wrapped around the free list ... no fit
  366.                  * found */
  367.         address = (char *) NULL;
  368.         break;
  369.     }
  370.     }
  371.  
  372.     /* End critical region */
  373.     (P4VOID) p4_unlock(shmem_lock);
  374.  
  375.     if (address == NULL)
  376.     p4_dprintf("xx_shmalloc: returning NULL; requested %d bytes\n",nbytes);
  377.     return address;
  378. }
  379.  
  380. P4VOID xx_shfree(ap)
  381. char *ap;
  382. {
  383.     Header *bp, *p;
  384.  
  385.     /* Begin critical region */
  386.     (P4VOID) p4_lock(shmem_lock);
  387.  
  388.     if (!ap)
  389.     return;            /* Do nothing with NULL pointers */
  390.  
  391.     bp = (Header *) ap - 1;    /* Point to block header */
  392.  
  393.     for (p = *freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
  394.     if (p >= p->s.ptr && (bp > p || bp < p->s.ptr))
  395.         break;        /* Freed block at start of end of arena */
  396.  
  397.     if (bp + bp->s.size == p->s.ptr)
  398.     {                /* join to upper neighbour */
  399.     bp->s.size += p->s.ptr->s.size;
  400.     bp->s.ptr = p->s.ptr->s.ptr;
  401.     }
  402.     else
  403.     bp->s.ptr = p->s.ptr;
  404.  
  405.     if (p + p->s.size == bp)
  406.     {                /* Join to lower neighbour */
  407.     p->s.size += bp->s.size;
  408.     p->s.ptr = bp->s.ptr;
  409.     }
  410.     else
  411.     p->s.ptr = bp;
  412.  
  413.     *freep = p;
  414.  
  415.     /* End critical region */
  416.     (P4VOID) p4_unlock(shmem_lock);
  417. }
  418. #endif
  419.  
  420. P4VOID get_pipe(end_1, end_2)
  421. int *end_1;
  422. int *end_2;
  423. {
  424.     int p[2];
  425.  
  426. #   if defined(IPSC860)  ||  defined(CM5)  ||  defined(NCUBE)
  427.     p4_dprintf("WARNING: get_pipe: socketpair assumed unavailable on this machine\n");
  428.     return;
  429. #   else
  430.     if (socketpair(AF_UNIX, SOCK_STREAM, 0, p) < 0)
  431.     p4_error("get_pipe: socketpair failed ", -1);
  432.     *end_1 = p[0];
  433.     *end_2 = p[1];
  434. #   endif
  435. }
  436.  
  437. P4VOID setup_conntab()
  438. {
  439.     int i, my_id;
  440.  
  441.     p4_dprintfl(60, "setup_conntab: myid=%d, switch_port=%d, app_id=%s\n",
  442.         p4_local->my_id,
  443.         p4_global->proctable[p4_local->my_id].switch_port,
  444.         p4_global->application_id);
  445.     p4_local->conntab = (struct connection *)
  446.     p4_malloc(p4_global->num_in_proctable * sizeof(struct connection));
  447.     my_id = p4_get_my_id();
  448.  
  449.     for (i = 0; i < p4_global->num_in_proctable; i++)
  450.     {
  451.     if (i == my_id)
  452.     {
  453.         p4_local->conntab[i].type = CONN_ME;
  454. #           if defined(IPSC860) || defined(CM5)  ||  defined(NCUBE)
  455.         p4_local->conntab[i].port = MYNODE();
  456. #           endif
  457. #           if defined(TCMP)
  458.         p4_local->conntab[i].port = i;
  459. #           endif
  460.     }
  461.     else if (in_same_cluster(i, my_id))
  462.     {
  463.         p4_local->conntab[i].type = CONN_LOCAL;
  464. #           if defined(IPSC860) || defined(CM5)  ||  defined(NCUBE)
  465.         p4_local->conntab[i].port = MYNODE() + i - p4_local->my_id;
  466. #           endif
  467. #           if defined(TCMP)
  468.         p4_local->conntab[i].port = i - p4_global->low_cluster_id;
  469. #           endif
  470.     }
  471.     else if ((p4_global->proctable[my_id].switch_port != -1) &&
  472.          (p4_global->proctable[i].switch_port != -1) &&
  473.          (p4_global->proctable[my_id].switch_port !=
  474.           p4_global->proctable[i].switch_port))
  475.     {
  476.         p4_local->conntab[i].type = CONN_REMOTE_SWITCH;
  477.         p4_local->conntab[i].switch_port = p4_global->proctable[i].switch_port;
  478.     }
  479.     else
  480.     {
  481.         p4_local->conntab[i].type = CONN_REMOTE_NON_EST;
  482.         p4_local->conntab[i].port = p4_global->proctable[i].port;
  483.     }
  484.     }
  485.     p4_dprintfl(60, "conntab after setup_conntab:\n");
  486.     dump_conntab(60);
  487. }
  488.  
  489. #ifdef SYSV_IPC
  490. P4VOID remove_sysv_ipc()
  491. {
  492.     int i;
  493.     struct p4_global_data *g = p4_global;
  494.  
  495.     /* ignore -1 return codes below due to multiple processes cleaning
  496.        up the same sysv stuff; commented out "if" used to make sure
  497.        that only the cluster master cleaned up in each cluster
  498.     */
  499.     /* if (p4_local != NULL  &&  p4_get_my_cluster_id() != 0) return; */
  500.  
  501.     if (sysv_shmid[0] == -1)
  502.     return;
  503.     for (i=0; i < sysv_num_shmids; i++)
  504.         shmctl(sysv_shmid[i],IPC_RMID,0);
  505.     if (g == NULL)
  506.         return;
  507.     if (sysv_semid0 != -1)
  508.     semctl(g->sysv_semid[0],0,IPC_RMID,0);  /* delete initial set */
  509.     for (i=1; i < g->sysv_num_semids; i++)  /* delete other sets */
  510.     {
  511.     semctl(g->sysv_semid[i],0,IPC_RMID,0);
  512.     }
  513. }
  514. #endif
  515.  
  516. int p4_wait_for_end()
  517. {
  518.     int status;
  519.     int i, n_forked_slaves, pid;
  520.     struct slave_listener_msg msg;
  521.  
  522.     ALOG_LOG(p4_local->my_id,END_USER,0,"");
  523.     ALOG_OUTPUT;
  524.     if (p4_get_my_cluster_id() != 0)
  525.     return;
  526.  
  527.     /* Wait for all forked processes except listener to die */
  528.     p4_dprintfl(90, "enter wait_for_end nfpid=%d\n",p4_global->n_forked_pids);
  529.     if (p4_local->listener_fd == (-1))
  530.         n_forked_slaves = p4_global->n_forked_pids;
  531.     else
  532.         n_forked_slaves = p4_global->n_forked_pids - 1;
  533.     for (i = 0; i < n_forked_slaves; i++)
  534.     {
  535.     pid = wait(&status);
  536.     p4_dprintfl(90, "detected that proc %d died \n", pid);
  537.     }
  538.  
  539. #   ifdef CAN_DO_SOCKET_MSGS
  540.     /* Tell the listener to die and wait for him to do so */
  541.     if (p4_local->listener_fd != (-1))
  542.     {
  543.     p4_dprintfl(90, "tell listener to die listpid=%d fd=%d\n",
  544.             p4_global->listener_pid, p4_local->listener_fd);
  545.     msg.type = p4_i_to_n(DIE);
  546.     msg.from = p4_i_to_n(p4_get_my_id());
  547.     net_send(p4_local->listener_fd, &msg, sizeof(msg), FALSE);
  548.     pid = wait(&status);
  549.     p4_dprintfl(90, "detected that proc %d died \n", pid);
  550.     }
  551. #   endif
  552.  
  553. #   ifdef SYSV_IPC
  554.     remove_sysv_ipc();
  555. #   endif
  556.  
  557.     if (p4_get_my_id())
  558.         p4_dprintfl(20,"process exiting\n");
  559.     p4_dprintfl(90, "exit wait_for_end \n");
  560.     return (0);
  561. }
  562.  
  563.  
  564. /* static variables private to fork_p4 and zap_p4_processes */
  565. static int n_pids = 0;
  566. static int pid_list[P4_MAXPROCS];
  567.  
  568. int fork_p4()
  569. /*
  570.   Wrapper round fork for sole purpose of keeping track of pids so 
  571.   that can signal error conditions.  See zap_p4_processes.
  572. */
  573. {
  574.     int pid;
  575.  
  576. #   if defined(IPSC860)  ||  defined(CM5)  ||  defined(NCUBE)
  577.     p4_error("fork_p4: nodes cannot fork processes",0);    
  578. #   else
  579.     if (p4_global->n_forked_pids >= P4_MAXPROCS)
  580.     p4_error("forking too many local processes; max = ", P4_MAXPROCS);
  581.     p4_global->n_forked_pids++;
  582.  
  583.     fflush(stdout);
  584.     pid = fork();
  585.  
  586.     if (pid > 0)
  587.     {
  588.     /* Parent process */
  589.     pid_list[n_pids++] = pid;
  590.     }
  591.     else if (pid == 0)
  592.     {
  593.     /* Child process */
  594.     pid_list[n_pids++] = getppid();
  595.     }
  596.     else
  597.     p4_error("fork_p4: fork failed", pid);
  598. #   endif
  599.  
  600.     return pid;
  601. }
  602.  
  603. P4VOID zap_p4_processes()
  604. {
  605.     int n;
  606.     
  607.     if (p4_global == NULL)
  608.         return;
  609.     n = p4_global->n_forked_pids;
  610.     while (n--)
  611.     {
  612.     kill(pid_list[n], SIGINT);
  613.     }
  614. }
  615.  
  616. P4VOID get_qualified_hostname(str)
  617. char *str;
  618. {
  619. #   if (defined(IPSC860)  &&  !defined(IPSC860_SOCKETS))  ||  \
  620.        (defined(CM5)      &&  !defined(CM5_SOCKETS))      ||  \
  621.        (defined(NCUBE)    &&  !defined(NCUBE_SOCKETS))
  622.     strcpy(str,"cube_node");
  623. #else
  624.     if (*str == '\0')
  625.         gethostname(str, 100);
  626.     if (*local_domain != '\0'  &&  !index(str,'.'))
  627.     {
  628.     strcat(str,".");
  629.     strcat(str,local_domain);
  630.     }
  631. #endif
  632. }
  633.  
  634.  
  635. int getswport(hostname)
  636. char *hostname;
  637. {
  638.     char local_host[256];
  639.  
  640. #ifdef CAN_DO_SWITCH_MSGS
  641.     if (strcmp(hostname, "local") == 0)
  642.     {
  643.     local_host[0] = '\0';
  644.     get_qualified_hostname(local_host);
  645.     return getswport(local_host);
  646.     }
  647.     if (strcmp(hostname, "hurley") == 0)
  648.     return 1;
  649.     if (strcmp(hostname, "hurley.tcg.anl.gov") == 0)
  650.     return 1;
  651.     if (strcmp(hostname, "hurley.mcs.anl.gov") == 0)
  652.     return 1;
  653.     if (strcmp(hostname, "campus.mcs.anl.gov") == 0)
  654.     return 2;
  655.     if (strcmp(hostname,"mpp1") == 0)
  656.       return 3;
  657.     if (strcmp(hostname,"mpp2") == 0)
  658.       return 28;
  659.     if (strcmp(hostname,"mpp3") == 0)
  660.       return 6;
  661.     if (strcmp(hostname,"mpp4") == 0)
  662.       return 7;
  663.     if (strcmp(hostname,"mpp7") == 0)
  664.       return 14;
  665.     if (strcmp(hostname,"mpp8") == 0)
  666.       return 25;
  667.     if (strcmp(hostname,"mpp9") == 0)
  668.       return 20;
  669.     if (strcmp(hostname,"mpp10") == 0)
  670.       return 11;
  671. #endif
  672.  
  673.     return -1;
  674. }
  675.  
  676. P4BOOL same_data_representation(id1,id2)
  677. {
  678.     struct proc_info *p1 = &(p4_global->proctable[id1]);
  679.     struct proc_info *p2 = &(p4_global->proctable[id2]);
  680.  
  681.     return (data_representation(p1->machine_type) == data_representation(p2->machine_type));
  682. }
  683.